system-linux: handle RTM_DELLINK events for device state tracking
authorFelix Fietkau <[email protected]>
Mon, 20 Oct 2025 17:43:27 +0000 (19:43 +0200)
committerFelix Fietkau <[email protected]>
Mon, 20 Oct 2025 17:46:54 +0000 (19:46 +0200)
Add RTM_DELLINK handling to properly track device lifecycle. When a
device is deleted, update its state with flags=0 to mark it as not
present. This improves synchronization compared to only relying on
the hotplug handler.

Signed-off-by: Felix Fietkau <[email protected]>
system-linux.c

index 65825352f9b08f43d165dba650bfa7c7fbb1e42a..ceeabe3a042a84e0746dad1e213d38aff0f55ef9 100644 (file)
@@ -732,8 +732,9 @@ static int cb_rtnl_event(struct nl_msg *msg, void *arg)
        struct ifinfomsg *ifi = NLMSG_DATA(nh);
        struct nlattr *nla[__IFLA_MAX];
        struct device *dev;
+       unsigned int flags;
 
-       if (nh->nlmsg_type != RTM_NEWLINK)
+       if (nh->nlmsg_type != RTM_NEWLINK && nh->nlmsg_type != RTM_DELLINK)
                return 0;
 
        nlmsg_parse(nh, sizeof(struct ifinfomsg), nla, __IFLA_MAX - 1, NULL);
@@ -744,7 +745,8 @@ static int cb_rtnl_event(struct nl_msg *msg, void *arg)
        if (!dev)
                return 0;
 
-       system_device_update_state(dev, ifi->ifi_flags);
+       flags = (nh->nlmsg_type == RTM_DELLINK) ? 0 : ifi->ifi_flags;
+       system_device_update_state(dev, flags);
        return 0;
 }